package top.caoayu.common.base;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import java.io.Serializable;
import java.util.Optional;

@Data
public class BasePageDTO<T> implements Serializable {
    private final static Long serialVersionUID = 1L;
    private Integer pageNum;
    private Integer pageSize;
    private String desc;
    private String asc;
    private Boolean total = true;

    public <T> Page<T> getPage() {
        Integer pageNum = Optional.ofNullable(this.getPageNum()).orElse(1);
        Integer pageSize = Optional.ofNullable(this.getPageSize()).orElse(20);
        Page<T> page = new Page<>(pageNum, pageSize, total);

        return page;
    }
}
